package com.hm.cms.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.hm.cms.su.BeanUtil;
import com.hm.cms.vo.HcmsPageBaseInfoVo.HcmsPageArticleNav;
import com.hm.common.su.bean.PageInfo;
import com.hm.common.util.CommonUtil;

import lombok.Data;

/**
 * @author shishun.wang
 * @date 2017年10月29日 下午2:17:29
 * @version 1.0
 * @describe 
 */
@Data
public class HcmsHomePageVo implements Serializable{

	private static final long serialVersionUID = -1318473551791666412L;

	private List<WebPageNavVo> webPageNavs = new ArrayList<WebPageNavVo>();
	
	private List<WebPageTagNavVo> webPageTagNavs = new ArrayList<WebPageTagNavVo>();
 
	@Data
	public static class WebPageTagNavVo implements Serializable{

		private static final long serialVersionUID = -1318473551791666412L;
	
		private String tagNavName;
		
		private String showMoreUri;
		
		private List<HcmsPageArticleNav> tagNavChilds = new ArrayList<HcmsPageArticleNav>();
		
		public WebPageTagNavVo tagNavChild(PageInfo<HcmsArticleVo> articleVos) {
			articleVos.getContent().parallelStream().forEach(articleVo -> {
				if(CommonUtil.isEmpty(articleVo)){
					return;
				}
				HcmsPageArticleNav articleNav = new HcmsPageArticleNav();
				BeanUtil.copyProperties(articleVo, articleNav);
				articleNav.setOpenUri(articleVo.getStaticizeUri());
				tagNavChilds.add(articleNav);
			});
			return this;
		}
	}
	
	@Data
	public static class WebPageNavVo implements Serializable{

		private static final long serialVersionUID = -1318473551791666412L;
		
		private String id;
	
		private String name;
		
		private String termTayCode;
		
		private String uri;
	}
}
